<?php
/**
 * DotHerbert
 *
 * @package    objects
 * @subpackage factory
 * @copyright  2009 extreme-programmers
 * @license    http://dotherbert.extreme-programmers.com/license   BSD License
 * @version    $Id:$
 */

namespace dotherbert\objects\factory\config;

/**
 * Object definition
 *
 * @package    objects
 * @subpackage factory
 * @author     Johannes Trink <johannes.trink@extreme-programmers.com>
 */
class Object
{
    /**
     * Scope singleton
     */
    const SCOPE_SINGLETON = 'singleton';

    /**
     * Scope prototype
     */
    const SCOPE_PROTOTYPE = 'prototype';

    private $id, $class, $factoryMethod, $properties = array(), $scope;

    /**
     * Constructor
     *
     * @param string $id
     * @param string $class
     * @param string $factoryMethod
     * @param string $scope
     */
    public function __construct($id = null, $class = null, $factoryMethod = null,
                                $scope = self::SCOPE_SINGLETON)
    {
        $this->id            = $id;
        $this->class         = $class;
        $this->factoryMethod = $factoryMethod;
        $this->scope         = $scope;
    }


    /**
     * Set id
     *
     * @param string $id
     * @return void
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * Get id
     *
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set scope
     *
     * @param string $scope
     * @return void
     */
    public function setScope($scope)
    {
        $this->scope = $scope;
    }

    /**
     * Get scope
     *
     * @return string
     */
    public function getScope()
    {
        return $this->scope;
    }

    /**
     * Set class
     *
     * @param string $class
     * @return void
     */
    public function setClass($class)
    {
        $this->class = $class;
    }

    /**
     * Get class
     *
     * @return string
     */
    public function getClass()
    {
        return $this->class;
    }

    /**
     * Set factory method
     *
     * @param string $factoryMethod
     * @return void
     */
    public function setFactoryMethod($factoryMethod)
    {
        $this->factoryMethod = $factoryMethod;
    }

    /**
     * Get factory method
     *
     * @return string
     */
    public function getFactoryMethod()
    {
        return $this->factoryMethod;
    }

    /**
     * Add property
     *
     * @param PropertyInterface $property
     * @return void
     */
    public function addProperty(PropertyInterface $property)
    {
        $this->properties[$property->getName()] = $property;
    }

    /**
     * Get property
     *
     * @param string $name
     * @return PropertyInterface
     */
    public function getProperty($name)
    {
        return $this->properties[$name];
    }

    /**
     * Get property definitions
     *
     * @return array
     */
    public function getProperties()
    {
        return $this->properties;
    }
}